 <!DOCTYPE html>
 <html lang="en">

 <head>
     <meta charset="UTF-8">
     <meta http-equiv="X-UA-Compatible" content="IE=edge">
     <meta name="viewport" content="width=device-width, initial-scale=1.0">
     <title>Document</title>
 </head>

 <body>
     <script src="EJSON.js"></script>
     <script>
        var obj = {
            name: 'EJSON',
            age: 12,
            test: 'test',
            'true': true,
            'false': false,
            'null': null,
            'undefined': undefined,
            '\"lover\"': {
                name: '\\\/mylover\'',
                age: 19,
                date: '\"2021-5-3\"'
            },
            friends: [
                {name: 'f1', age: 18},
                {name: 'f2', age: 19},
                {name: 'f3', age: 20}
            ]
        }
        var log = console.log;
        log('将对象解析成JSON字符串:');
        var str = EJSON.stringify(obj);
        log(str);
        log('--------------------');
        log('将JSON字符串解析成JS对象:')
        var obj = EJSON.parse(str);
        log(obj);
        log('--------------------');
        log('obj["lover"]:');
        log(obj['\"lover\"']);
        log('--------------------');
        log('obj[friends]:');
        for (var i = 0; i < obj.friends.length; i++) {
            log(obj.friends[i]);
        }

        var e = '{ \"a\" : 123, \"b\" : false, \"c\" :  \"null}';
        EJSON.parse(e);
        // var e = '{ \"a\" : 123, \"b\" : false, \"c\" : \"null\", \"d\" : what? }'
        // EJSON.parse(e);
     </script>
 </body>

 </html>